import 'package:flutter/material.dart';
import 'package:sample2/model/chat/chat_channel.dart';
import 'package:sample2/pages/chat/chat_conversation.dart';

class ChatChannelItem extends StatefulWidget {
  final ChatChannel channelItem;
  const ChatChannelItem({super.key, required this.channelItem});

  @override
  State<StatefulWidget> createState() {
    return ChatChannelItemState();
  }
}

class ChatChannelItemState extends State<ChatChannelItem> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.of(context).pushNamed('/chatGroup', arguments: {
          "kind": ChatConversationKind.peer2group,
          "channel": widget.channelItem
        });
      },
      highlightColor: Colors.lightBlue,
      child: Ink(
          color: Colors.white,
          child: Container(
            decoration: const BoxDecoration(color: Colors.white10),
            constraints: const BoxConstraints(minHeight: 60, maxHeight: 80),
            padding: const EdgeInsets.all(13.0),
            child: Row(
              children: [
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "${widget.channelItem.channelName}",
                      style: const TextStyle(
                          color: Colors.black,
                          fontSize: 18,
                          fontWeight: FontWeight.bold),
                    ),
                    const Spacer(),
                    Text(
                      "${widget.channelItem.channelDesc}",
                      style: const TextStyle(color: Colors.grey),
                    )
                  ],
                ),
              ],
            ),
          )),
    );
  }
}
